<template>
    <div id="goods" class="box">
        <table class="table">
            <thead>
                <th>编号</th>
                <th>名称</th>
                <th>标题</th>
                <th>单价</th>
                <th>库存</th>
                <th>操作</th>
            </thead>
            <tbody>
                <tr v-for="goodItem in goodItems" v-bind:key="goodItem.id">
                    <td>{{ goodItem.id }}</td>
                    <td>{{ goodItem.goodsName }}</td>
                    <td>{{ goodItem.goodsTitle }}</td>
                    <td>{{ goodItem.goodsPrice }}</td>
                    <td>{{ goodItem.goodsStock }}</td>
                    <td><button class="button is-primary" v-on:click="doSeckill(goodItem)">秒杀</button></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script>
import {mapGetters} from 'vuex';

export default {
    name: 'GoodList',
    computed: {
        ...mapGetters([
            'goodItems'
        ])
    },
    methods: {
        doSeckill(goodItem) {
            console.log('开始秒杀:' + goodItem.id);
            this.$router.push({path: '/seckill/' + goodItem.id})
        }
    }
}
</script>

<style scoped>

</style>